package main.Q2601_2700;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class Q2601_2610 {
    public static void main(String[] args) {
        System.out.println("Question2601：");
        System.out.println("Question2602：");
        System.out.println("Question2603：");
        System.out.println("Question2604：");
        System.out.println("Question2605：");
        System.out.println("Question2606：");
        System.out.println("Question2607：");
        System.out.println("Question2608：");
        System.out.println("Question2609：");
        System.out.println("Question2610：转换二维数组");
    }
}

class Question2610 {
    public List<List<Integer>> findMatrix(int[] nums) {
        Map<Integer, Integer> map = new HashMap<>();
        List<List<Integer>> result = new ArrayList<>();
        for (int num : nums) {
            map.put(num, map.getOrDefault(num, 0) + 1);
        }
        while (!map.isEmpty()) {
            List<Integer> temp = new ArrayList<>(), zeroList = new ArrayList<>();
            for (int key : map.keySet()) {
                temp.add(key);
                map.put(key, map.get(key) - 1);
                if (map.get(key) == 0) zeroList.add(key);
            }
            for (int zero : zeroList) {
                map.remove(zero);
            }
            result.add(temp);
        }
        return result;
    }
}